'use strict';

Object.defineProperty(exports, "__esModule", {
    value: true
});
/**
 * 基本Promise生成器类
 * created by wjxu on 2017-02-20T15:23:43+0800
 * @param  {String} options.url      请求地址
 * @param  {String} options.type     请求方式Get/Post
 * @param  {String} options.dataType 相应数据格式
 * @param  {Object} options.params   请求的参数
 * @return {Promise}                 生成的Promise实例
 */
function myPromise(_ref) {
    var ajax = _ref.ajax,
        url = _ref.url,
        _ref$type = _ref.type,
        type = _ref$type === undefined ? 'GET' : _ref$type,
        _ref$dataType = _ref.dataType,
        dataType = _ref$dataType === undefined ? 'json' : _ref$dataType,
        _ref$params = _ref.params,
        params = _ref$params === undefined ? {} : _ref$params;

    var promise = new Promise(function (resolve, reject) {
        ajax({
            url: url,
            type: type,
            dataType: dataType,
            data: params,
            success: function success(data) {
                resolve(data);
            },
            error: function error(_error) {
                reject(_error);
            }
        });
    });
    return promise;
};
exports.myPromise = myPromise;